#!/bin/bash

##添加host,避免访问不到配置
sh host.sh

##环境变量重载，避免java mvn找不到
source /etc/profile

##启动seata，分布式事务
sh seata.sh

## 项目编译，防止最新改动不生效
sh build.sh

##停止之前的项目，防止端口冲突
sh stop.sh

##建立日志路径
mkdir -p /data/technology-cloud/logs/

# 定义变量
COLLECTION_PATH="/data/technology-cloud/technology-collection/target/"
COLLECTION_LOG="/data/technology-cloud/logs/technology-collection.log"

GATEWAY_PATH="/data/technology-cloud/technology-gateway/target/"
GATEWAY_LOG="/data/technology-cloud/logs/technology-gateway.log"

MONITOR_PATH="/data/technology-cloud/technology-monitor/target/"
MONITOR_LOG="/data/technology-cloud/logs/technology-monitor.log"

RESOURCE_PATH="/data/technology-cloud/technology-resource/target/"
RESOURCE_LOG="/data/technology-cloud/logs/technology-resource.log"

STATISTICS_PATH="/data/technology-cloud/technology-statistics/target/"
STATISTICS_LOG="/data/technology-cloud/logs/technology-statistics.log"

# 执行命令并输出日志
cd $COLLECTION_PATH && java -jar *.jar > $COLLECTION_LOG &
cd $GATEWAY_PATH && java -jar *.jar > $GATEWAY_LOG &
cd $MONITOR_PATH && java -jar *.jar > $MONITOR_LOG &
cd $RESOURCE_PATH && java -jar *.jar > $RESOURCE_LOG &
cd $STATISTICS_PATH && java -jar *.jar > $STATISTICS_LOG &

echo '项目启动成功。。'
echo '日志目录：./logs/'